<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<head th:include="common/header"></head>
<body>
	<div class="layui-fluid">

		<!-- 导航菜单 -->
		<div th:replace="common/system/system_fragment :: system_menu('BUG管理')"></div>

		<!-- 当前位置 -->
		<div th:replace="common/system/system_fragment :: system_locations('BUG管理', 'BUG管理', '编辑信息')"></div>
		
		<div class="layui-row  yy-margin-top-10">
		
			<fieldset>
				<legend><a>基本信息</a></legend>
			
				<form class="layui-form" method="post">
				<!-- 查询 -->
					<div class="layui-colla-item">
						<div class="layui-form layui-form-pane">
							<input type="hidden" name="id" th:value="${bug.id}">
							<!-- bug标题 -->
							<div class="layui-form-item">
								<label class="layui-form-label layui-bg-orange">标题</label>
								<div class="layui-input-block">
									<input th:value="${bug.title}" type="text" name="title" autocomplete="off" class="layui-input" lay-verify="required|length50" placeholder="请输入标题">
								</div>
							</div>
							
							<!-- bug状态 -->
							<div class="layui-form-item">
								<label class="layui-form-label layui-bg-orange">状态</label>
								<div class="layui-input-block">
									<!-- 状态：1.新建  2.已经解决  3.关闭  4.拒绝  5.驳回 6.重开 -->
									<input type="radio" name="status" title="新建" value="1" th:checked="${bug.status eq '1'}" />
									<input type="radio" name="status" title="解决" value="2" th:checked="${bug.status eq '2'}" />
									<input type="radio" name="status" title="关闭" value="3" th:checked="${bug.status eq '3'}" />
									<input type="radio" name="status" title="拒绝" value="4" th:checked="${bug.status eq '4'}" />
									<input type="radio" name="status" title="驳回" value="5" th:checked="${bug.status eq '5'}" />
									<input type="radio" name="status" title="重开" value="6" th:checked="${bug.status eq '6'}" />
								</div>
							</div>
							
							<!-- 描述信息 -->
							<div class="layui-form-item">
								<label class="layui-form-label layui-bg-orange">描述</label>
								<div class="layui-input-block">
									<textarea class="layui-textarea layui-hide" id="bugContent" name="content" lay-verify="maxLength|layeditContent" th:text="${bug.content}"></textarea>
								</div>
							</div>
							
							<!-- 提交及取消按钮 -->
							<div class="layui-form-item">
								<div class="layui-input-block">
									<a class="layui-btn yy-float-right yy-margin-right-10" lay-submit="" lay-filter="bug">确定</a>
									<a class="layui-btn yy-float-right" href="javascript:history.go(-1);">返回</a>
								</div>
							</div>
						</div>
					</div>
				</form>
			</fieldset>
		
		</div>
		
	</div>

	<!-- 引入js -->
	<div th:replace="common/script"></div>
	
	<script type="text/javascript">
	/*<![CDATA[*/
	
	;!function(){
		//初始化副文本编辑器
		var layedit = layui.layedit, form = layui.form;
		
		//自定义工具栏以及上传地址
		var index = layedit.build('bugContent', {
		    tool: ['image', 'strong'],
			height: 300,
			uploadImage:{
				url:"/images/upload",
				type:"post"
			}
		});
		
		//验证表单，将富文本编辑器的值放到文本域中 
		form.verify({
			maxLength:function(value){
				if(value.length > 1000){
					return "bug描述内容过长!";
				}
			},
			layeditContent:function(value){
				layedit.sync(index);
			}
		});
		
		//表单提交事件
		form.on('submit(bug)', function(data){
			
			$.http.submitForm({
				url:"/bug/savebug",
				data:data.field,
				success:function(r){
					if(r && r.success){
						$.prompt.alert(r.msg, "/bug/bugList");
					}
				}
			});
			
			return false; //阻止表单跳转。因为使用ajax所以这里阻止表单的自动跳转
		});
		
	}();
	
	/*]]>*/
	</script>
</body>

</html>